GBML manual / Strings

string_slice

Up to count characters of s, starting at start (0-based) - taking part of a string.

Syntax

string_slice(s, start, count) -> string

Arguments

NameType
sstring
startint
countint

Returns

string

Description

Up to count characters of s, starting at start (0-based) - taking part of a string.

start/count are clamped, never a crash: a start past the end (or negative) reads as "nothing left to take", and a count running past the end of s is shortened to whatever is actually there.

Example

var call_sign = "FALCON-9";
var prefix = string_slice(call_sign, 0, 6);
var suffix = string_slice(call_sign, 7, 1);
var matches = prefix == "FALCON";

The result can never be longer than s itself, so only your project's own Longest string setting can ever truncate it further - call string_length on the result if you need to confirm nothing was cut.

On the GBA

start/count are CLAMPED, never a crash: a start past the end (or negative) reads as "nothing left to take", and a count running past the end of s is quietly shortened to whatever is actually there. The result can never be longer than s itself, so only capacities.maxStringLength (this call's own {scap}) can ever truncate it further - see string_length on the result if you need to confirm nothing was cut.

See also: string_lengthstring_char_atstring_find